# $Id$
# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Tobias Kieslich <tobias@justdreams.de>
# Contributor: tobias <tobias@archlinux.org>

pkgname=inkscape
pkgver=0.92.2
pkgrel=3
pkgdesc='Professional vector graphics editor'
url='https://inkscape.org/'
license=('GPL' 'LGPL')
arch=('i686' 'x86_64')
makedepends=('boost' 'intltool')
depends=('gc' 'gsl' 'gtkmm' 'gtkspell' 'imagemagick' 'libxslt' 'poppler-glib'
         'popt' 'potrace' 'ttf-dejavu' 'python2' 'libcdr'
         'desktop-file-utils' 'hicolor-icon-theme')
optdepends=('gvfs: import clip art'
            'pstoedit: latex formulas'
            'python2-scour: optimized SVG output'
            'texlive-core: latex formulas'
            'python2-numpy: some extensions'
            'python2-lxml: some extensions and filters'
            'uniconvertor: reading/writing to some proprietary formats')
source=("https://media.inkscape.org/dl/resources/file/${pkgname}-${pkgver}.tar.bz2"
        poppler-0.58.patch)
sha256sums=('a628d0e04c254e9840947e6d866974f92c68ae31631a38b94d9b65e5cd84cfd3'
            '0505f49cf69ad51159cda5aa5f497f001fe9d10f34d59e6ad704a1b1e1dc50c1')

# NB: Some CDN nodes appear to be distributing an outdated version of this file.

prepare() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	# https://gitlab.com/inkscape/inkscape/commit/93ccf03162cd2e46d962822d5507865f3451168c
	patch -Np1 -i ../poppler-0.58.patch

	./autogen.sh

	sed -i 's|/usr/bin/python\>|/usr/bin/python2|g' cxxtest/*.py
	sed -i 's|/usr/bin/env python\>|/usr/bin/env python2|g' share/*/{test/,}*.py
	sed -i 's|"python" },|"python2" },|g' src/extension/implementation/script.cpp
	sed -i 's|python -c|python2 -c|g' configure share/extensions/uniconv*.py
	sed -i 's|"python"|"python2"|g' src/main.cpp

	sed -i 's| abs(| std::fabs(|g' src/ui/tools/flood-tool.cpp
}

build() {
	cd "${srcdir}/${pkgname}-${pkgver}"

	./configure \
		--prefix=/usr \
		--with-python \
		--with-perl \
		--enable-lcms \
		--enable-poppler-cairo \
		--disable-strict-build \
		--disable-dependency-tracking
	make
}

package() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	make DESTDIR="${pkgdir}" install
}
